package com.zuimei.zuimei.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zuimei.zuimei.fragments.FindAppItem1Fragment;
import com.zuimei.zuimei.fragments.FindAppItem2Fragment;
import com.zuimei.zuimei.fragments.FindAppItem3Fragment;
import com.zuimei.zuimei.fragments.FindAppItem4Fragment;
import com.zuimei.zuimei.fragments.FindAppItem5Fragment;

/**
 * Created by Jogger on 2017/1/16.
 * 发现页适配器
 */

public class FindAppFragmentPagerAdapter extends FragmentPagerAdapter {
    private String[] mTabTitle;

    public FindAppFragmentPagerAdapter(FragmentManager fm, String[] tabTitle) {
        super(fm);
        mTabTitle = tabTitle;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return new FindAppItem1Fragment();
        }
        if (position == 1) {
            return new FindAppItem2Fragment();
        }
        if (position == 2) {
            return new FindAppItem3Fragment();
        }
        if (position == 3) {
            return new FindAppItem4Fragment();
        }
        if (position == 4) {
            return new FindAppItem5Fragment();
        }
        return null;
    }

    @Override
    public int getCount() {
        return mTabTitle.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTabTitle[position % mTabTitle.length];
    }
}
